package day13.XianCheng;

public class Lian12 {
    public static void main(String[] args) {
//        method1();
//        method2();
    }

    private static void method2() {
        MyRunable2 mr=new MyRunable2();
        Thread t1=new Thread(mr);
        Thread t2=new Thread(mr);
        t1.setName("老大");
        t2.setName("老二");
        t1.start();
        t2.start();
    }

    private static void method1() {
        MyThread2 t1=new MyThread2("小王");
        MyThread2 t2=new MyThread2("小绿");
        t1.start();
        t2.start();
    }
}
class MyThread2 extends Thread{
    public MyThread2() {
    }

    public MyThread2(String name) {
        super(name);
    }

    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            System.out.println(getName()+"--"+i);
        }
    }
}

class MyRunable2 implements Runnable{

    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            System.out.println(Thread.currentThread().getName()+"--"+i);
        }
    }
}
